package com.example.home.adapter.provider

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.home.R
import com.example.home.adapter.NominateItemType
import com.example.home.databinding.ItemHomeSingleTitleBinding
import com.example.entity.BaseEntity
import com.example.home.entity.viewdata.SingleTitleViewData

class SingleTitleProvider : BaseItemProvider<BaseEntity>() {
    override val itemViewType: Int=NominateItemType.SINGLE_TITLE_VIEW
    override val layoutId: Int= R.layout.item_home_single_title

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<ItemHomeSingleTitleBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: BaseEntity) {
        var dataBinding= helper.getBinding<ItemHomeSingleTitleBinding>()
        if (item != null && dataBinding!= null){
            var entity = item as SingleTitleViewData
            dataBinding.viewData = entity

            dataBinding.executePendingBindings()
        }

    }
}